package domain.valueObejcts;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;

@Entity
public class Location implements Serializable {

	private static final long serialVersionUID = 1L;
	public static final String BAR = "Bar";
	public static final String JUMPER = "Jumper";
	public static final String FIRST = "I";
	public static final String SECOND = "II";
	public static final String THIRD = "III";
	public static final String FOURTH = "IV";
	public static final String FIFTH = "V";
	public static final String SUPER_VISIOR = "Aufsicht";
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@SequenceGenerator(name = "location_gen", sequenceName = "location_id_seq")
	private int id;
	private String number;
	private String type;
	private int countPersons;
	private int xPos;
	private int yPos;
	@OneToOne
	@JoinColumn
	private Floor floor;

	private transient List<ProjectPosition> positions;
	
	public Location(){
		
	}
	
	public int getId() {
		return this.id;
	}
	
	public void setId(int id) {
		this.id = id;
	}

	public int getxPos() {
		return xPos;
	}

	public void setxPos(int xPos) {
		this.xPos = xPos;
	}

	public int getyPos() {
		return yPos;
	}
	
	public void setyPos(int yPos) {
		this.yPos = yPos;
	}
	
	public String getNumber() {
		return number;
	}

	public void setNumber(String number) {
		this.number = number;
	}
	
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public int getCountPersons() {
		return countPersons;
	}

	public void setCountPersons(int countPersons) {
		this.countPersons = countPersons;
	}
	
	public void setFloor(Floor floor){
		this.floor = floor;
	}
	public Floor getFloor(){
		return this.floor;
	}
	
	public List<ProjectPosition> getPositions(){
		return this.positions;
	}

	@Override
	public String toString() {
		return this.type + " " + this.number;
	}
	
	@Override
	public boolean equals(Object obj) throws ClassCastException{
		if(obj instanceof Location){
			Location tmp = (Location)obj;
			if(tmp.getFloor().equals(this.floor) && tmp.getNumber().equals(this.number)){
				return true;
			}
			return false;
		} else {
			throw new ClassCastException();
		}
	}

}
